<template>
  <div class="app-container">
    订单列表
  <!-- 表格 -->
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="数据加载中"
      border
      fit
      highlight-current-row>

      <el-table-column
        label="序号"
        width="70"
        align="center">
        <template slot-scope="scope">
          {{ (page - 1) * limit + scope.$index + 1 }}
        </template>
      </el-table-column>

      <el-table-column prop="courseTitle" label="课程名称" width="160" />

      <el-table-column prop="teacherName" label="讲师名称" width="160" />


      <el-table-column label="课程状态" width="80">
        <template slot-scope="scope">
          {{ scope.row.status===1?'已付款':'未付款' }}
        </template>
      </el-table-column>    


      <el-table-column label="课程状态" width="80">
        <template slot-scope="scope">
          {{ scope.row.payType===1?'微信':'支付宝' }}
        </template>
      </el-table-column>  

      <el-table-column prop="totalFee" label="价格" width="80"/>


      <el-table-column prop="gmtCreate" label="订单生成时间" width="160"/>


      <el-table-column label="操作" width="100" align="center">
        <template slot-scope="scope">
          <el-button type="danger" size="mini" icon="el-icon-delete" @click="removeDataById(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
        
      
    </el-table>

    <!-- 分页 -->
    <el-pagination
      :current-page="page"
      :page-size="limit"
      :total="total"
      style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper"
      @current-change="getOrderList"
    />

  </div>
</template>
<script>
import order from '@/api/edu/order'
export default {

    data() {
        return{
            list:null,
            listp:null,
            page:1,
            limit:5,
            total:0
        }
    },
    created() {
        this.getOrderList()
    },
    methods:{
        removeDataById(OrderId){
           this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
          }).then(() => {
              return order.deleteOrderById(OrderId)
          }).then(() => {
              this.getOrderList()
              this.$message({
                  type: 'success',
                  message: '删除成功!'
              })
          })
        },
        getOrderList(page = 1){
          order.getAllOrder(this.page = page,this.limit)
           .then(response=>{
            this.list=response.data.orders;
            this.total = response.data.total;
           }).catch(error => {
                console.log(error)
            })
          
        }
    }
}
</script>